package com.yizhubao.app.presenters;

import com.yizhubao.app.base.BasePresenter;
import com.yizhubao.app.base.BaseResultBean;
import com.yizhubao.app.beans.WXLoginBean;
import com.yizhubao.app.models.PayModel;
import com.yizhubao.app.models.WXLoginModel;
import com.yizhubao.app.utils.Utils;
import com.yizhubao.app.utils.net.BaseObserver;
import com.yizhubao.app.views.PayView;
import com.yizhubao.app.views.WXLoginView;

import java.util.Map;

import h.framework.pacy.utils.LogUtil;

/**
 * @author Pacy.
 * Date: 2021/6/9/009
 * Time: 21:17
 * Mail pengwwe457621023@qq.com
 * Info 微信登录
 */
public class PayPresenter extends BasePresenter<PayView> {
    private PayModel model;

    public PayPresenter() {
        model = new PayModel();
    }

    public void payRequest(Map<String, Object> map) {
        model.pay(map, new BaseObserver<String>() {
            @Override
            public void onSuccess(BaseResultBean<String> t) {
                LogUtil.i("微信登录---"+t.toString());
                if (isViewAttached()) {
                    getView().onPaySuccess(t.getData());
                }
            }

            @Override
            public void onError(String errMessage) {
                if (isViewAttached()) {
                    getView().showFailure(errMessage);
                }
            }

            @Override
            public void onComplete() {
                super.onComplete();
                if (isViewAttached()) {
                    getView().showFinished();
                }

            }
        }, getView().getLifeSubject());
    }

}
